The invention relates generally to a method and system for providing shared resources, and, more specifically, to a method and system for providing a group of parallel resources as a proxy for a single shared resource.
It is common for a program that is executing on a computer system to transfer data to another program. For example, a spreadsheet program may transfer data comprising the results of calculations to a graphing program, which would then present the transferred data visually as a graph. Programs that participate in such data transfer are referred to herein as xe2x80x9ccommunicating programs.xe2x80x9d In a particular transfer, the program transferring data is called the xe2x80x9ctransferer,xe2x80x9d and the program to which data are transferred is called the xe2x80x9ctransferee.xe2x80x9d In some cases, there may be more than one transferee in a single transfer, each of which receives the transferred data.
A communicating program usually performs data transfers using one or more published data transfer protocols in order to maximize the number of other programs to or from which it can transfer data. Many such data transfer protocols, referred to herein as xe2x80x9cshared memory protocols,xe2x80x9d specify that the transferer stores the transferred data in memory accessible to both programs, then passes a reference to the transferee, which uses the reference to access the transferred data. A reference may be a pointer or a handle which may be converted to a pointer.
FIG. 1 is a flow diagram illustrating a data exchange between two communicating programs using a shared memory protocol. The steps shown in FIG. 1 are organized into two columns: the left column contains steps 102, 103, 104, 105, and 108B, which are performed by the transferor, and the right column contains steps 101, 106, 107, and 108A, which are performed by the transferee. In step 101, the transferee requests data from a transferor. This involves transmitting a request identifying the requested data from the transferee to the transferor via an interprocess communication mechanism. For example, the transferee may send a message to the transferor, or may call a notification routine of the transferor. In step 102, the transferor receives the request for data transmitted by the transferee in step 101. In step 103, the transferor allocates a global memory block that will be accessible to both the transferor and the transferee. As part of the allocation process, the transferor receives a reference to the allocated global memory block. In step 104, the transferor uses the reference to store the data identified in the request received in step 102 in the allocated global memory block. In step 105, the transferor uses an interprocess communication mechanism to transmit the reference to the global memory block to the transferee. In step 106, the transferee receives the reference to the global memory block transmitted by the transferor in step 105. In step 107, the transferee uses the reference received in step 106 to access the data in the global memory block. In step 108A, after it has finished accessing the data in the global memory block, the transferee deallocates the global memory block so that it may be allocated again for another use. Alternatively, in step 108B, the transferor deallocates the global memory block, either a predetermined length of time after it transmits the reference in step 105, or when subsequently notified by the transferee that the transferee has finished accessing the data in the global memory block (not shown). Each individual protocol either specifies that the transferee deallocates the global memory block (step 108A), that the transferor deallocates the global memory block (step 108B), or that the transferee and the transferor negotiate via interprocess communication to themselves determine which program will deallocate the global memory block (not shown).
The services used by communicating programs to allocate, write to, read from (or xe2x80x9caccessxe2x80x9d), and deallocate memory blocks as described above are generally provided by other, centralized programs in the computer system comprising an operating system. While many operating systems provide a memory allocation service that enables a transferor to allocate a global memory block that is accessible to both the transferor and a transferee in step 105, some operating systems do not provide a memory allocation service that enables a transferor to allocate a global memory block that is accessible to the transferee. When communicating programs are executed on a computer system having an operating system whose memory allocation service does not enable a transferor to allocate a global memory block that is accessible to both the transferor and the transferee, data transfers via shared memory between the communicating programs are prevented, since the allocation step 103 succeeds, but the accessing step 107 fails and the transferee is unable to read the transferred data from the allocated block.
For instance, some operating systems that support the execution of both programs compiled for 16-bit word size and programs compiled for 32-bit word size do not allocate memory blocks accessible to other programs in response to a request from a program compiled for 32-bit word size to allocate a global memory block. This prevents data transfers using shared memory where the transferor is a program compiled for 32-bit word size. Further, in such an operating system, the references to memory blocks holding transferred data stored in the transfer message are formatted differently for programs compiled for 16-bit word size and programs compiled for 32-bit word size. As a result, the transferee in a shared memory data transfer is unable to use the reference stored in the transfer message to access the transferred data where it was compiled for a different word size than was the transferor, as the reference has the wrong format.
Further, some operating systems perform the interprocess communication between steps 105 and 106 in two or more xe2x80x9cstagesxe2x80x9d that each require the execution of a separate program within the operating system or associated with the receiver. Debugging programs for monitoring interprocess communication traffic may incorporate themselves in, or xe2x80x9chook,xe2x80x9d any of these intermediate programs, intercept the data transfer communication, and use the reference inside to access the transferred data. If the global data block allocated in step 103 is not accessible to an intermediate program, it will not be accessible to a debugging tool that incorporates itself in the intermediate program, thereby frustrating the purpose of the debugging program.
It is an object of the invention to provide a method and system in a computer system for providing a group of parallel resources as a proxy for a single shared resource.
It is another object of the invention to provide a method and system in a computer system for providing one or more private memory blocks in the place of a global memory block.
It is yet another object of the invention to provide a method and system in a computer system for facilitating shared memory data transfer from one transferor program to one or more transferee programs without utilizing global memory blocks.
It is a further object of the invention to provide a method and system in a computer system for maintaining and deleting groups of parallel resources.
These and other objects, which will become apparent as the invention is more fully described below, are provided by a method and system for providing a group of parallel resources as a proxy for a single shared resource. In a preferred embodiment, a resource grouping facility (xe2x80x9cthe facilityxe2x80x9d) emulates the sharing of a resource between two programs that cannot both directly access the resource. The facility first receives an indication that a first program is attempting to provide a public original resource to a second program. The facility, in response to receiving the indication, creates a private proxy resource from the public original resource that is accessible to the second program. The facility then provides the private proxy resource it has created to the second program.
In a further preferred embodiment, the facility is incorporated in a xe2x80x9cnon-globalxe2x80x9d operating system. A non-global operating system is an operating system that is unable to respond correctly to a request to allocate a global resource of a particular type, such as a memory block, that can be accessed by every program executing in conjunction with the operating system. Instead, a non-global operating system allocates a putatively global resource that may not be accessed by every program executing in conjunction with the non-global operating system. When the facility detects that a transferor program is attempting to share with a transferee program a putatively global resource allocated by the operating system, the facility allocates a proxy resource that is accessible to the transferee. The facility may also allocate one or more intermediate resources accessible to other programs. The facility tracks the putatively global resource and all of the proxy resources as a proxy group. In a preferred embodiment, the facility also copies characteristics of the putatively global resource to the proxy resources. For example, where the putatively global resource and the proxy resources are memory blocks, the facility preferably copies the contents of the putatively global memory block to the proxy memory blocks. When the facility detects that a program is attempting to deallocate a member of the proxy group, that is, a putatively global resource or one of its proxies, the facility preferably deallocates each member of the proxy group.